<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
    
    <head>
        <meta charset="UTF-8">
        <title></title>
<!--        <meta name="renderer" content="webkit">-->
<!--        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">-->
<!--        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />-->
        <link rel="stylesheet"  th:href="@{/X-admin/css/font.css}">
        <link rel="stylesheet" th:href="@{/X-admin/css/xadmin.css}">
        <script th:src="@{/X-admin/lib/layui/layui.js}" charset="utf-8"></script>
        <script type="text/javascript" th:src="@{/X-admin/js/xadmin.js}"></script>
    </head>
    
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="#">首页</a>
                <a href="#">演示</a>
                <a>
                    <cite>导航元素</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5" th:action="@{/admin/queryStuWithCondition/1}">

                                <div class="layui-input-inline layui-show-xs-block">
                                    <select name="school">
                                        <option value="" name="school">学院分类</option>
                                        <option th:each="schools:${schooltype}" th:text="${schools.getSchool()}" th:selected="${school==schools.getSchool()}"
                                                th:value="${schools.getSchool()}" name="school"></option>
                                    </select>
                                </div>
                                <div class="layui-input-inline layui-show-xs-block">
                                    <select name="gender" th:value="${gender}=='M'?'男':'女'">
                                        <option value="" name="gender" >性别</option>
                                        <option value="M" name="gender" th:selected="${gender=='M'}">男</option>
                                        <option value="F" name="gender" th:selected="${gender=='F'}">女</option>
                                    </select>
                                </div>
                                <div class="layui-input-inline layui-show-xs-block">
                                    <input type="text" name="id" placeholder="请输入学号" th:value="${id}"  autocomplete="off" class="layui-input"></div>
                                <div class="layui-input-inline layui-show-xs-block">
                                    <button class="layui-btn" lay-submit="" lay-filter="sreach" type="submit">
                                        <i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加选手','/admin/toAdd',500,600)">
                                <i class="layui-icon"></i>添加</button></div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                                <thead>
                                    <tr>
                                        <th>学号</th>
                                        <th>姓名</th>
                                        <th>性别</th>
                                        <th>学院</th>
                                        <th>电话</th>
                                        <th>邮箱</th>
                                        <th>密码</th>
                                        <th>操作</th></tr>
                                </thead>
                                <tbody>
                                    <tr th:each="students:${pageInfo.list}">

                                        <td th:text="${students.getId()}"></td>
                                        <td th:text="${students.getName()}"></td>
                                        <td th:text="${students.getGender()=='M'?'男':'女'}"></td>
                                        <td th:text="${students.getSchool()}"></td>
                                        <td th:text="${students.getPhone()}"></td>
                                        <td th:text="${students.getEmail()}"></td>
                                        <td th:text="${students.getPassword()}"></td>

                                        <td class="td-manage">
                                            <a title="查看" class="updStu"  href="javascript:;">
                                                <i class="layui-icon">&#xe63c;</i></a>
                                            <a title="删除" class="delStu" onclick="member_del(this,'要删除的id')" href="javascript:;">
                                                <i class="layui-icon">&#xe640;</i></a>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

                        <h3>当前第[[${pageInfo.getPageNum()}]]页，总共[[${pageInfo.getPages()}]]页，总共[[${pageInfo.getTotal()}]]条记录</h3>
                        <!--这里是分页信息--不带条件-->
                        <div class="layui-card-body " th:if="${sign=='getStu'}">
                            <div class="page">
                                <a class="num" th:href="@{/admin/getStu/1}" >首页</a>
                                <inline th:if="${pageInfo.hasPreviousPage}"><!--如果存在前一页-->
                                    <a class="prev" th:href="@{/admin/getStu/}+${pageInfo.getPageNum()-1}">&lt;&lt;</a></inline>

                                <inline th:each="page:${pageInfo.getNavigatepageNums()}">
                                    <inline th:if="${page==pageInfo.getPageNum()}">
                                        <span class="current" th:text="${pageInfo.getPageNum()}"></span>
                                    </inline>
                                    <inline th:if="${page!=pageInfo.getPageNum()}">
                                        <a class="prev" th:text="${page}" th:href="@{/admin/getStu/}+${page}"></a>
                                    </inline>
                                </inline>

                                <inline th:if="${pageInfo.hasNextPage}"><!--如果存在后一页-->
                                    <a class="next" th:href="@{/admin/getStu/}+${pageInfo.getPageNum()+1}">&gt;&gt;</a></inline>
                                <a class="num" th:href="@{/admin/getStu/}+${pageInfo.getPages()}" >末页</a>
                            </div>
                        </div>

                            <!--这里是分页信息--带条件-->
                        <div class="layui-card-body " th:if="${sign=='getStuWithCondition'}">
                            <div class="page">
                                <a class="num" th:href="@{/admin/queryStuWithCondition/1}" >首页</a>
                                <inline th:if="${pageInfo.hasPreviousPage}"><!--如果存在前一页-->
                                    <a class="prev" th:href="@{/admin/queryStuWithCondition/}+${pageInfo.getPageNum()-1}">&lt;&lt;</a></inline>

                                <inline th:each="page:${pageInfo.getNavigatepageNums()}">
                                    <inline th:if="${page==pageInfo.getPageNum()}">
                                        <span class="current" th:text="${pageInfo.getPageNum()}"></span>
                                    </inline>
                                    <inline th:if="${page!=pageInfo.getPageNum()}">
                                        <a class="prev" th:text="${page}" th:href="@{/admin/queryStuWithCondition/}+${page}"></a>
                                    </inline>
                                </inline>

                                <inline th:if="${pageInfo.hasNextPage}"><!--如果存在后一页-->
                                    <a class="next" th:href="@{/admin/queryStuWithCondition/}+${pageInfo.getPageNum()+1}">&gt;&gt;</a></inline>
                                <a class="num" th:href="@{/admin/queryStuWithCondition/}+${pageInfo.getPages()}" >末页</a>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </body>
    <script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
    <script type="text/javascript">


    </script>

    <script>
        $(".updStu").click(function () {
            //layer.alert("点击事件");
            var stuId= $(this).parents("tr").find("td:eq(0)").text();
            $(this).attr("onclick",xadmin.open('编辑','/admin/toUpd/'+stuId,500,600));
        })


        layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });

        /*用户-删除*/
        $(".delStu").click(function () {
            //layer.alert("点击事件");
            var stuId= $(this).parents("tr").find("td:eq(0)").text();
            $(this).attr("onclick",member_del(this,stuId));
        })
        var stuId= $(this).parents("tr").find("td:eq(0)").text();
        function member_del(obj, stuId) {
            layer.confirm('确认要删除吗？',
            function(index) {
                //发异步删除数据
                $.ajax({
                    url:"/admin/delStuById/"+stuId,
                    type:"DELETE",
                    success:function () {
                        //$(obj).parents("tr").remove();
                        layer.alert('已删除!', {
                            icon: 1,
                            time: 1000
                        });
                        setTimeout(function () {
                            window.location.reload();
                        }, 2000);
                    }
                })

            });
        }

    </script>

</html>